Purpose
Unlike the getTime task (which provides a system timestamp), the addDuration task allows you to add a duration of time and then return the adjusted timestamp for continued use in the automation.
Potential Use Case
If there is a date value provided in a record, you could use the addDuration task to determine what the timestamp would be if additional time were added. Let's use the example of adding 6 months to a poll record. Using this task, the automation run would generate a result similar to the following: "Last poll occurred on 01JAN, next poll will occur on 01JUN".
Properties
Input and output properties are shown below.
| Incoming | Type | Description |
|---|---|---|
inputTime |
Object | Required. A timestamp provided from the result of a previous automation task. |
offsetDuration |
Object | Required. A duration to offset the current time expressed as an object literal notation. For example: {"days": 7,"months":1} will add 7 days and 1 month to the current system timestamp. Numeric values entered without any other designators will be treated as milliseconds (default). |
Note: If using object literal notations in the
offsetDurationproperty, you must include the curly braces in the value. See examples below. For more information regarding the object literal notation, see the moment.js documentation.
| Outgoing | Type | Description |
|---|---|---|
newTime |
Object | The new time that is returned after adding the given duration to the inputTime object. |
Note: The
newTimeobject will inherit the same format as the providedinputTime. Currently the addDuration task does not provide a mechanism to alter the time format.
Example 1
In this example from IAP:
The
inputTimeproperty is provided by theGet timetask, which is located elsewhere in the workflow. The reference variable istime.Using the object literal notation, the
offsetDurationwill add four (4) days to the time input value.
The outgoing
newTimevariable will be the result of adding 4 days to theinputTimevalue that was provided at the time the incoming properties were set.Using this example, let's say the
inputTimevariable was "2020-06-01". Adding 4 days would mean the resultingnewTimewould be "2020-06-05".
Example 2
In this IAP example:
The
inputTimeproperty is provided by theGet timetask, which is located elsewhere in the workflow. The reference variable istime.Notice that the
timevariable provided by theGet timereference task should have anoffsetDurationof 8640000 milliseconds (24 hours) added to it. By default, this field accepts values as milliseconds and does not require the object literal notation.
The outgoing
newTimevariable will be the result of adding 24 hours to theinputTimevalue that was provided.
Example 3
In this IAP example:
The
inputTimeproperty is provided by theGet timetask, which is located elsewhere in the workflow. The reference variable istime.The
timevariable provided by theGet timereference task should have anoffsetDurationof 4 hours and 6 months added to it. Notice the use of the object literal notation.
The outgoing
newTimevariable will be the result of adding 6 months and 4 hours to theinputTimevalue that was provided.
Manual Reference Variable Entry (inputTime)
To enter the inputTime object manually, use the format below for Year-Month-Date-Time ("yyyy-MM-dd 'T' HH:mm:ss.SSSZ").
{"time": "2021-02-26T15:00:00.000Z"}
This format shows as:
2021-02-25 03:00.00